#include<iostream>
#include<fstream>
#include<vector>
#include<set>
#include<string>
#include<cctype>
#include<algorithm>
#include<cstdio>
using namespace std;
vector<string> save_words;
vector<string> unknow_words;
void get_DB(string filename)
{
	if(filename=="NULL")
		return ;
	fstream file(filename.c_str(),ios::in);
	string str;
	while(file>>str)
	{
		save_words.push_back(str);
		str.clear();
	}
	sort(save_words.begin(),save_words.end());
	
	file.close();
}
void save_DB(string filename)
{
	fstream file(filename.c_str(),ios::out);
	for(int i=0;i<(int)unknow_words.size();i++)
	{
		save_words.push_back(unknow_words[i]);
	}
	sort(save_words.begin(),save_words.end());
	vector<string>::iterator buf=unique(save_words.begin(),save_words.end());
	save_words.erase(buf,save_words.end());
	for(int i=0;i<(int)save_words.size();i++)
	{
		file<<save_words[i]<<endl;
	}
	
	file.close();
}
void write_in_words(string str)
{
	save_words.push_back(str);
	sort(save_words.begin(),save_words.end());
	vector<string>::iterator buf=unique(save_words.begin(),save_words.end());
	save_words.erase(buf,save_words.end());
}
void find_words(string str)
{
	bool find_if=false;
	for(int i=0;i<(int)save_words.size();i++)
	{
		if(save_words[i]==str)
			find_if=true;
	}
	if(find_if)
	{
		return ;
	}
	else
	{
		unknow_words.push_back(str);
	}
	
}
void get_unknow()
{
	sort(unknow_words.begin(),unknow_words.end());
	vector<string>::iterator buf=unique(unknow_words.begin(),unknow_words.end());
	unknow_words.erase(buf,unknow_words.end());
	for(int i=0;i<(int)unknow_words.size();i++)
	{
		cout<<unknow_words[i]<<endl;
	}
	cout<<"total "<<unknow_words.size()<<" words you may not know--------------"<<endl; 
}
void get_words()
{
	char in;
	string word;
	while(in!='^')
	{
		in=getchar();
		if(isupper(in)||islower(in))
		{
			in=tolower(in);
			word+=in;
		}
		else
		{
			if(!word.empty())
			{
				find_words(word);
				word.clear();
			}
		}
	}
}
int main()
{
	string str;
	cout<<"input your DB's name.if you don't have DB ,input NULL"<<endl;
	cin>>str;
	get_DB(str);
	cout<<"please input the artcle and end it with '^' "<<endl;
	get_words();
	cout<<endl;
	system("cls"); 
	cout<<"------------the-words-you-do-not-know-----------"<<endl;
	get_unknow();
	cout<<"input the name of the DB that you want to save"<<endl;
	cin>>str;
	save_DB(str);
	return 0;
}
